﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SnmpSharpNet;

namespace Alex.Library.Snmp.Windows
{
    /// <summary>
    /// 存储对象
    /// </summary>
    public class HrStorage
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public HrStorage()
        {

        }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="oid">存储oid</param>
        public HrStorage(Oid oid)
        {
            this.oid = oid;
        }

        /// <summary>
        /// 存储对象oid
        /// </summary>
        public Oid oid { get; set; }

        /// <summary>
        /// 存储对象描述
        /// </summary>
        public string descr { get; set; }

        /// <summary>
        /// 每箸/块的大小
        /// </summary>
        public int allocationUnits { get; set; }

        /// <summary>
        /// 箸/块总数
        /// </summary>
        public double size { get; set; }

        /// <summary>
        /// 已使用的箸/块个数
        /// </summary>
        public double used { get; set; }

        /// <summary>
        /// 使用率
        /// </summary>
        public double usage 
        {
            get
            {
                return (this.size != 0 && this.allocationUnits != 0)
                    ? this.used / this.size
                    : 0;
            }
        }

        /// <summary>
        /// 可读的磁盘容量(GB)
        /// </summary>
        public int friendlySizeGB
        {
            get
            {
                return (int)Math.Floor(this.size * this.allocationUnits / Math.Pow(1024, 3));
            }
        }

        /// <summary>
        /// 可读的磁盘使用量(GB)
        /// </summary>
        public int friendlyUsedGB
        {
            get
            {
                return (int)Math.Floor(this.used * this.allocationUnits / Math.Pow(1024, 3));
            }
        }
    }

    /// <summary>
    /// 网络接口对象
    /// </summary>
    public class Interfaces
    {
        /// <summary>
        /// 网络接口对象Oid
        /// </summary>
        public Oid oid { get; set; }
        /// <summary>
        /// 网络接口描述
        /// </summary>
        public string descr { get; set; }
        /// <summary>
        /// 端口类型:6:ethernet, 71: ieee 802.11(Wi-Fi)
        /// </summary>
        public int ifType { get; set; }
        /// <summary>
        /// 最大传输包字节数
        /// </summary>
        public int ifMtu { get; set; }
        /// <summary>
        /// 端口速度
        /// </summary>
        public int ifSpeed { get; set; }
        /// <summary>
        /// MAC地址
        /// </summary>
        public string ifPhysAddress { get; set; }
        /// <summary>
        /// 输入字节数
        /// </summary>
        public long ifInOctets { get; set; }
        /// <summary>
        /// 输出字节数
        /// </summary>
        public long ifOutOctets { get; set; }
    }
    /// <summary>
    /// Tcp连接状态
    /// </summary>
    public enum TcpConnState
    {
        closed = 1,
        listen = 2,
        synSent = 3,
        synReceived = 4,
        established = 5,
        finWait1 = 6,
        finWait2 = 7,
        closeWait = 8,
        lastAck = 9,
        closing = 10,
        timeWait = 11,
        deleteTCB = 12
    }

    /// <summary>
    /// Tcp连接对象
    /// </summary>
    public class TcpConnEntry
    {
        /// <summary>
        /// Tcp连接状态
        /// </summary>
        public TcpConnState tcpConnState { get; set; }
        /// <summary>
        /// Tcp连接本地IP地址
        /// </summary>
        public string tcpConnLocalAddress { get; set; }
        /// <summary>
        /// Tcp连接本地端口号
        /// </summary>
        public int tcpConnLocalPort { get; set; }
        /// <summary>
        /// Tcp连接远程IP地址
        /// </summary>
        public string tcpConnRemAddress { get; set; }
        /// <summary>
        /// Tcp连接远程端口号
        /// </summary>
        public int tcpConnRemPort { get; set; }
    }
    /// <summary>
    /// Tcp端口信息对象
    /// </summary>
    public class TcpSummary
    {
        /// <summary>
        /// 接收的数据段个数
        /// </summary>
        public int tcpInSegs { get; set; }
        /// <summary>
        /// 发送的数据段个数
        /// </summary>
        public int tcpOutSegs { get; set; }
        /// <summary>
        /// 重新传输的数据段个数
        /// </summary>
        public int tcpRetransSegs { get; set; }
        /// <summary>
        /// 当前连接数
        /// </summary>
        public int tcpCurrEstab { get; set; }
        /// <summary>
        /// 重置连接数
        /// </summary>
        public int tcpEstabResets { get; set; }
        /// <summary>
        /// 主动开放数
        /// </summary>
        public int tcpActiveOpens { get; set; }
        /// <summary>
        /// 被动开放数
        /// </summary>
        public int tcpPassiveOpens { get; set; }
        /// <summary>
        /// 失败的连接尝试次数
        /// </summary>
        public int tcpAttemptFails { get; set; }
        /// <summary>
        /// Tcp连接对象列表
        /// </summary>
        public List<TcpConnEntry> tcpConnTable { get; set; }
    }

    /// <summary>
    /// Udp连接对象
    /// </summary>
    public class UdpConnEntry
    {
        /// <summary>
        /// Udp连接本地IP地址
        /// </summary>
        public string udpLocalAddress { get; set; }
        /// <summary>
        /// Udp连接本地端口号
        /// </summary>
        public int udpLocalPort { get; set; }
    }

    /// <summary>
    /// Udp端口汇总信息对象
    /// </summary>
    public class UdpSummary
    {
        /// <summary>
        /// 接收的数据包个数
        /// </summary>
        public int udpInDatagrams { get; set; }
        /// <summary>
        /// 无端口数
        /// </summary>
        public int udpNoPorts { get; set; }
        /// <summary>
        /// 接收错误数
        /// </summary>
        public int udpInErrors { get; set; }
        /// <summary>
        /// 发送的数据包个数
        /// </summary>
        public int udpOutDatagrams { get; set; }
        /// <summary>
        /// Udp连接对象列表
        /// </summary>
        public List<UdpConnEntry> udpConnTable { get; set; }
    }
    /// <summary>
    /// 程序类别
    /// </summary>
    public enum HrSWType
    {
        unknown = 1,
        operatingSystem = 2,
        deviceDriver = 3,
        application = 4
    }

    /// <summary>
    /// 程序运行状态
    /// </summary>
    public enum HrSWRunStatus
    {
        running = 1,
        runnable = 2,
        notRunnable = 3,
        invalid = 4
    }

    /// <summary>
    /// 进程信息对象
    /// </summary>
    public class SystemProcess
    {
        /// <summary>
        /// 进程名称
        /// </summary>
        public string hrSWRunName { get; set; }
        /// <summary>
        /// 进程文件路径
        /// </summary>
        public string hrSWRunPath { get; set; }
        /// <summary>
        /// 进程运行参数
        /// </summary>
        public string hrSWRunParameters { get; set; }
        /// <summary>
        /// 进程类别
        /// </summary>
        public HrSWType hrSWRunType { get; set; }
        /// <summary>
        /// 进程运行状态
        /// </summary>
        public HrSWRunStatus hrSWRunStatus { get; set; }
        /// <summary>
        /// 进程从开始运行总共用了多少厘秒(百分之一秒)的CPU
        /// </summary>
        public int hrSWRunPerfCPU { get; set; }
        /// <summary>
        /// 进程被分配的内存大小（KBytes）
        /// </summary>
        public int hrSWRunPerMem { get; set; }
    }
    /// <summary>
    /// 安装程序信息对象
    /// </summary>
    public class InstalledSoftWare
    {
        /// <summary>
        /// 程序名称
        /// </summary>
        public string hrSWInstalledName { get; set; }
        /// <summary>
        /// 程序类型
        /// </summary>
        public HrSWType hrSWInstalledType { get; set; }
        /// <summary>
        /// 程序最后修改时间
        /// </summary>
        public DateTime hrSWInstalledDate { get; set; } //The last-modification date of this application as it would appear in a directory listing.
    }
}
